home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20031118-20041115
/
000400_dm_v_2000@yahoo.com_Wed Sep 22 13:15:12 2004.msg
< prev
next >
Wrap
Internet Message Format
|
2004-11-14
|
6KB
Path: newsmaster.cc.columbia.edu!newsfeed1.nycmny01.us.to.verio.net!newspeer1.stngva01.us.to.verio.net!verio!newsfeed.vmunix.org!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnews1.google.com!not-for-mail
From: dm_v_2000@yahoo.com (Peter V.)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Return codes and If statments
Date: 22 Sep 2004 09:53:34 -0700
Organization: http://groups.google.com
Lines: 171
Message-ID: <3f9c05b0.0409220853.25e5bd46@posting.google.com>
References: <3f9c05b0.0409211252.5aa51cb1@posting.google.com> <slrncl18i5.56s.fdc@sesame.cc.columbia.edu> <1095827419.338981.28270@k26g2000oda.googlegroups.com>
NNTP-Posting-Host: 206.6.159.100
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1095872014 30819 127.0.0.1 (22 Sep 2004 16:53:34 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 22 Sep 2004 16:53:34 +0000 (UTC)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15178
Frank and Mark,
thank you both for your advice. I am sticking to recommended format
Number 2, and that seems to have done the trick.
Once again, thanks.
Peter Vasseur
"Mark Sapiro" <slash_dev_slash_null_2000@yahoo.com> wrote in message news:<1095827419.338981.28270@k26g2000oda.googlegroups.com>...
> Frank da Cruz wrote:
> > On 2004-09-21, Peter V. <dm_v_2000@yahoo.com> wrote:
> > : I am modifying a C-Kermit script I have to not continue processing
> > : if a call to another script does not return a value of 1 (We are
> doing
> > : this for fail over testing).
> > :
> > : Here is the C-Kermit code in question:
> > :
> > : # run the db_status script in the CRON directory
> > : run db_status
> > :
> > : # See if the ret value is != 1
> > : # If it != 1 tell user we are not on the primay server and then
> > : exit).
> > :
> > : if != \v(pexitstat) 1
> > : {
> > : echo Return code != 1 ... Not the primary server
> > : echo return code = \v(pexitstat)
> > : exit
> > :
> > : }
> > : # otherwise we are on the primary server so continue processing
> > : ...
> > : ...
> > : ...
> > :
> > : When I run this on the Secondary server it works (since the result
> > : returned from the db_status script is a 2 since it is not the
> primary
> > : server).
> > :
> > : However, when I test this on the primay server the code exits
> (meaning
> > : it executes the body of the if statment above) despite the fact
> that
> > : the return code from db_status is 1.
> > :
> > : Any suggestions, as to what I'm doing wrong?
> > :
> > My first suggestion is to use the recommended format for grouping
> statements:
> >
> > if != \v(pexitstat) 1 {
> > echo Return code != 1 ... Not the primary server
> > echo return code = \v(pexitstat)
> > exit
> > }
> >
> > If that doesn't help, then check to see what the subprocess actually
> > returns as its exit code (OK, you say it is 1 but...). If so, then
> make sure
> > you are running the current version of C-Kermit, which is 8.0.211.
> If you
> > are, then we're in for some debugging; contact
> kermit-support@columbia.edu.
> >
> > - Frank
>
>
> Frank's suggestion will help. This is another case of if { } else { }
> constructs that only work if written in certain ways.
>
> I've mentioned this before, but the document
>
> http://www.columbia.edu/kermit/ckermit70.html
>
> contains several examples of if/else coding in section 7.20.1. The
> first four of these are
>
> Example 1:
>
> IF condition { command1, command2 } ELSE { command3, command4 }
>
> Example 2 (same as Example 1):
>
> IF condition {
> command1
> command2
> } ELSE {
> command3
> command4
> }
>
> Example 3 (same as 1 and 2):
>
> IF condition {
> command1
> command2
> }
> ELSE { command3, command4 }
>
> Example 4 (same as 1-3):
>
> IF condition {
> command1
> command2
> }
> ELSE {
> command3
> command4
> }
>
> In examples 3 and 4, various problems occur in execution of the ELSE
> clause when the condition is false. This change happened somewhere
> between 8.0.201 and 8.0.206 due to changes in the handling of
> "immediate macros". This is illustrated by the following.
>
> fog: {14} $ cat kt3
> # Example 1:
>
> IF false { .theday := \v(day), show macro theday } ELSE { .thedate :=
> \v(date), show macro thedate }
>
> # Example 2 (same as Example 1):
>
> IF false {
> .theday := \v(day)
> show macro theday
> } ELSE {
> .thedate := \v(date)
> show macro thedate
> }
>
> # Example 3 (same as 1 and 2):
>
> IF false {
> .theday := \v(day)
> show macro theday
> }
> ELSE { .thedate := \v(date), show macro thedate }
>
> # Example 4 (same as 1-3):
>
> IF false {
> .theday := \v(day)
> show macro theday
> }
> ELSE {
> .thedate := \v(date)
> show macro thedate
> }
> fog: {15} $ kermit
> Executing /home_mo/msapiro/.kermrc for UNIX...
> Executing /home_mo/msapiro/.mykermrc...
> Good Evening.
> C-Kermit 8.0.212 Dev.00, 10 May 2004, for HP-UX 11.00
> Copyright (C) 1985, 2004,
> Trustees of Columbia University in the City of New York.
> Type ? or HELP for help.
> (/home_mo/msapiro/) C-Kermit>take kt3
> thedate = 21 Sep 2004
> thedate = 21 Sep 2004
> thedate = \v(date)
> thedate = \v(date)
> (/home_mo/msapiro/) C-Kermit>
>
> I have trained myself to always code if/else in the "recommended
> format", but it would be nice if the examples that no longer work were
> removed from the documentation.